home *** CD-ROM | disk | FTP | other *** search
- Path: crl.crl.com!not-for-mail
- From: bobfry@crl.com (Robert Fry)
- Newsgroups: comp.lang.c
- Subject: Re: Bit Masking
- Date: 10 Jan 1996 16:09:10 -0800
- Organization: CRL Dialup Internet Access
- Message-ID: <4d1kf7$ffu@crl.crl.com>
- References: <DKz5y4.8En@twisto.eng.hou.compaq.com>
- NNTP-Posting-Host: crl.com
-
- garyc%cs%contractors@bangate.compaq.com (Gary Clarke) writes:
-
- >Can someone tell me the elegent way to clear specific bits from a
- >byte, e.g.
-
- ># define BIT_1 1
- ># define BIT_2 2
- ># define BIT_3 4
- ># define BIT_4 8
-
- >Set the bit: x |= BIT_x
-
- >Clear the bit using BIT_x: ????
-
- Most people I know use: x &= ~BIT_x
-
- Be careful of data item size problems, however. Not all compilers will
- generate the code you want when x is not an int.
-
- Bob
-